import csv

def analyze_starbucks_data(file_path):
    """分析星巴克门店分布数据"""
    stores = []
    with open(file_path, 'r', encoding='utf-8') as file:
        reader = csv.reader(file)
        headers = next(reader)  # 读取标题行
        # 确定城市和国家列的索引
        city_index = 5  # 第六列是城市
        country_index = 7  # 第八列是国家
        # 读取数据
        for row in reader:
            if len(row) > max(city_index, country_index):
                stores.append({
                    'city': row[city_index],
                    'country': row[country_index]
                })
    return stores

def main():
    """主函数，处理命令行输入并输出结果"""
    file_path = 'directory.csv'  # 直接使用固定文件名
    stores = analyze_starbucks_data(file_path)
    
    # 读取查询条件
    query = input().strip()
    parts = query.split(' ', 1)
    
    query_type, query_value = parts
    query_type = int(query_type)
    
    if query_type == 1:
        # 按国家查询
        count = sum(1 for store in stores if store['country'] == query_value)
        print(count)
    elif query_type == 2:
        # 按城市查询
        count = sum(1 for store in stores if store['city'] == query_value)
        print(count)

if __name__ == "__main__":
    main()